package com.itheima.test2;

import com.itheima.domain.Student;

import java.io.*;
import java.util.ArrayList;

public class Test04 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {

        //method01();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("day13\\students.txt"));
       ArrayList<Student> list= (ArrayList<Student>) ois.readObject();
        System.out.println(
                list
        );
        ois.close();
    }

    public static void method01() throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("day13\\students.txt"));
        Student cai = new Student("蔡徐坤", 28, "淖马村");
        Student wu = new Student("吴亦凡", 28, "海淀监狱");
        Student li = new Student("李云迪", 28, "朝阳派出所");
        ArrayList<Student> list = new ArrayList<>();
        list.add(cai);
        list.add(wu);
        list.add(li);


        oos.writeObject(list);
        oos.close();
    }
}
